<?php
class Aclplugin extends Zend_Controller_Plugin_Abstract {
  private $_acl = null;
 
  public function __construct(Zend_Acl $acl) {
    $this->_acl = $acl;
  }
 
  public function preDispatch(Zend_Controller_Request_Abstract $request) {
    $role = (Zend_Auth::getInstance()->hasIdentity())
          ? 'user'
          : 'guest';
          
          
    $resource = $request->getControllerName();
    $action = $request->getActionName();
    
    if(!$this->_acl->isAllowed($role, $resource, $action)) {
    	$Front = Zend_Controller_Front::getInstance();
    	$redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
        $redirector->gotoUrl('auth/login');
        
        
//    	$request->setModuleName('default')
//              ->setControllerName('auth')
//              ->setActionName('login');
    }
    else
    {
//    	echo "+++";
    }
  }
}